package com.yuyue.springFramework.note05.annotation;

import org.springframework.context.annotation.*;

import javax.sql.DataSource;

/**
 * 创建配置类
 */
//注册Config类
@Configuration
//扫描com及其子包，并注册bean
@ComponentScan(basePackages = "com")
//扫描+过滤
//@ComponentScan(basePackages = "com",
//        includeFilters = @ComponentScan.Filter(type = FilterType.REGEX,pattern = ".*.*.note05.*.*"),
//        excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX,pattern = ".*.*.note05.*.RequireEntity"))
//配置文件路径注解
@PropertySource("classpath:application.properties")
//引入XML配置文件,此配置会导致前面案例中 @Value 的值找不到情况，启动容器报错
//@ImportResource("classpath:config.xml")
public class AppConfig {
    @Bean
    @Profile("development")
    public DataSource developmentDataSource() {
        System.out.println("测试环境数据源");
        return null;
    }

    @Bean
    @Profile("production")
    public DataSource productionDataSource() {
        System.out.println("生产环境数据源");
        return null;
    }

    @Bean
    @Profile("default")
    public DataSource defaultDataSource() {
        //System.out.println("默认数据源");
        return null;
    }
}
